package entity

import (
	"fmt"
	"time"

	"gorm.io/gorm"
	"shqsoft.cn/pas3ui/base"
)

//ShIndiFbblczsdr 非保本理财中收导入
type ShIndiFbblczsdr struct {
	ID   int       `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	SJRQ time.Time `gorm:"column:SJRQ"`
	CPDM string    `gorm:"column:CPDM"`
	ZSJE float64   `gorm:"column:ZSJE"`
	QGR  time.Time `gorm:"column:QGR"`
	JZR  time.Time `gorm:"column:JZR"`
	ISCL int       `gorm:"column:ISCL"`
	PUID int       `gorm:"column:PUID"`
}

//TableName
func (ShIndiFbblczsdr) TableName() string {
	return "SH_INDI_FBBLCZS"
}

// BeforeCreate
func (u *ShIndiFbblczsdr) BeforeCreate(tx *gorm.DB) (err error) {
	err = base.CHDB.Raw("SELECT PUID FROM T_INDI_FAPU WHERE PUNO=?", u.CPDM).Row().Scan(&u.PUID)
	if err != nil {
		err = fmt.Errorf("产品代码%s在系统中不存在！", u.CPDM)
		return
	}
	return
}

//ShIndiFbblczsdrEF 返回结构体
func ShIndiFbblczsdrEF() base.EntityFunc {
	return func() interface{} {
		entity := ShIndiFbblczsdr{}
		return &entity
	}
}

//ShIndiFbblczsdrESF 返回结构体数组
func ShIndiFbblczsdrESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []ShIndiFbblczsdr
		return &entities
	}
}

func init() {
	base.DaoPoolObj.Put("ShIndiFbblczsdr", base.NewDefaultDao(ShIndiFbblczsdrEF(), ShIndiFbblczsdrESF(), nil, "my"))
}
